package core

import (
	"sync"
)

var PipeManagerOnce sync.Once

type PipeManager struct {
	Pipes map[string]Pipe
}

/**
获取实例
*/
func GetInstance() PipeManager {
	var pipeManager PipeManager
	PipeManagerOnce.Do(func() {
		pipeManager = PipeManager{}
	})
	return pipeManager
}

/**
注册
*/
func (PipeManager *PipeManager) Register(name string, pipe Pipe) {
	manager := GetInstance()

	manager.Pipes[name] = pipe
}

/**
解救
*/
func (PipeManager *PipeManager) Unreguster(name string) {
	manager := GetInstance()
	delete(manager.Pipes, name)
}

func init() {
	GetInstance()
}
